package net.suncaper.demo.service;

import net.suncaper.demo.domain.Order;
import net.suncaper.demo.domain.OrderExample;
import net.suncaper.demo.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService{
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public List<Order> findOrder() {
        return orderMapper.selectByExample(new OrderExample());
    }

    @Override
    public void saveOrder(Order order){
        orderMapper.insert(order);
    }

    @Override
    public List<Order> selectByStatus(String status, Long userid){
        return orderMapper.selectByStatus("%"+status+"%",userid);
    }

    @Override
    public Order selectByPrimaryKey(long orderID){
        Order order=orderMapper.selectByPrimaryKey(orderID);
        return order;
    }

    @Override
    public void cancel(Order order) {
        orderMapper.updateByPrimaryKey(order);
    }

    @Override
    public void updateStatus(Long orderid) {
        orderMapper.updateStatus(orderid);
    }

}
